package com.caipiao.controller;

import com.caipiao.mapper.SUserMemberMapper;
import com.caipiao.pojo.ObjectResult;
import com.caipiao.pojo.SUserMember;
import com.caipiao.pojo.XMLBean;
import com.caipiao.service.MemberService;
import com.caipiao.util.CommonUtils;
import com.caipiao.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Administrator on 2019/1/8.
 */
@Controller
@RequestMapping("/member")
public class MemberController {

    @Autowired
    private MemberService memberService;
    @Autowired
    private SUserMemberMapper sUserMemberMapper;


    /**
     * 关注的专家
     * @param xmlBean
     * @return
     */
    @RequestMapping(value = "/myFollow",method = RequestMethod.POST)
    @ResponseBody
    public ObjectResult myFollow(XMLBean xmlBean){
        if (StringUtil.isEmpty(xmlBean.getToken())) return ObjectResult.build("0","未登录");
        return memberService.memberFollow(xmlBean);
    }

    /**
     * 关注专家的方案
     * @param xmlBean
     * @return
     */
    @RequestMapping(value = "/plan",method = RequestMethod.POST)
    @ResponseBody
    public ObjectResult plan(XMLBean xmlBean){
        if (StringUtil.isEmpty(xmlBean.getToken())) return ObjectResult.build("0","未登录");
        return memberService.memberPlan(xmlBean);
    }

    /**
     * 添加关注
     * @param xmlBean
     * @return
     */
    @RequestMapping(value = "/follow",method = RequestMethod.POST)
    @ResponseBody
    public ObjectResult follow(XMLBean xmlBean){
        if (StringUtil.isEmpty(xmlBean.getToken())) return ObjectResult.build("0","未登录");
        return memberService.foller(xmlBean);
    }

    /**
     * 专家详情
     * @param xmlBean
     * @return
     */
    @RequestMapping(value = "/details",method = RequestMethod.POST)
    @ResponseBody
    public ObjectResult details(XMLBean xmlBean){
        return memberService.memberDetails(xmlBean);
    }

    @RequestMapping(value = "/list")
    @ResponseBody
    public ObjectResult list(XMLBean xmlBean){
        return memberService.memberList(xmlBean);
    }

}

